<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>开始使用layui</title>
    <link rel="stylesheet" href="../layui/css/layui.css">
</head>
<body>

<!-- 你的HTML代码 -->
<div class="layui-tab" lay-allowClose="true" lay-filter="insertTab">
    <ul class="layui-tab-title">
        <li class="layui-this">标题一</li>
        <li>标题二</li>
        <li>标题三</li>
    </ul>
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">内容1</div>
        <div class="layui-tab-item">内容2</div>
        <div class="layui-tab-item">内容3</div>
    </div>
    <div class="layui-table">
        <table id="demo" lay-filter="test"></table>
    </div>
    <div>
        <button class="layui-btn" id="insert" >插入选项卡</button>
    </div>
</div>


<script src="../layui/layui.js"></script>
<script>


    layui.use(['table','layer','element'],function () {
        var table = layui.table
            ,element = layui.element
            ,layer = layui.layer
            ,$ = layui.$;

        table.render({
            elem:'#demo'
            ,height:315
            ,url: 'user.txt' //数据接口
            ,page: true //开启分页
            ,cols: [[ //表头
                {field: 'id', title: 'ID', width:80, sort: true, fixed: 'left'}
                ,{field: 'username', title: '用户名', width:80}
                ,{field: 'sex', title: '性别', width:80, sort: true}
                ,{field: 'city', title: '城市', width:80}
                ,{field: 'sign', title: '签名', width: 177}
                ,{field: 'experience', title: '积分', width: 80, sort: true}
                ,{field: 'score', title: '评分', width: 80, sort: true}
                ,{field: 'classify', title: '职业', width: 80}
                ,{field: 'wealth', title: '财富', width: 135, sort: true}
            ]]
        });

        $("#insert").on('click',function (data){
        layer.msg("testadada");
            element.tabAdd('insertTab',{
                title:'新增的选项~',
                content:'动态新增选项卡内容',
                id:'123'
            });

        });



    });





</script>
</body>
</html>
